Micron Document
<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Banker's algorithm</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Banker's_algorithm"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Banker_s_algorithm rootpage-Banker_s_algorithm skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Banker's algorithm</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<p><b>Banker's algorithm</b> is a <a href="Resource_allocation" title="Resource allocation">resource allocation</a> and <a href="Deadlock_(computer_science)" title="Deadlock (computer science)">deadlock</a> avoidance <a href="Algorithm" title="Algorithm">algorithm</a> developed by <a href="Edsger_Dijkstra" class="mw-redirect" title="Edsger Dijkstra">Edsger Dijkstra</a> that tests for safety by simulating the allocation of predetermined maximum possible amounts of all <a href="Resource_(computer_science)" class="mw-redirect" title="Resource (computer science)">resources</a>, and then makes an "s-state" check to test for possible deadlock conditions for all other pending activities, before deciding whether allocation should be allowed to continue.
</p><p>The algorithm was developed in the design process for the <a href="THE_(operating_system)" class="mw-redirect" title="THE (operating system)">THE operating system</a> and originally described (in <a href="Dutch_language" title="Dutch language">Dutch</a>) in EWD108.<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> When a new process enters a system, it must declare the maximum number of instances of each resource type that it may ever claim; clearly, that number may not exceed the total number of resources in the system. Also, when a process gets all its requested resources it must return them in a finite amount of time.
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="Resources">Resources</h2></div>
<p>For the Banker's algorithm to work, it needs to know three things:
</p>
<ul><li>How much of each resource each process could possibly request ("MAX")</li>
<li>How much of each resource each process is currently holding ("ALLOCATED")</li>
<li>How much of each resource the system currently has available ("AVAILABLE")</li></ul>
<p>Resources may be allocated to a process only if the amount of resources requested is less than or equal to the amount available; otherwise, the process waits until resources are available.
</p><p>Some of the resources that are tracked in real systems are <a href="Memory_(computers)" class="mw-redirect" title="Memory (computers)">memory</a>, <a href="Semaphore_(programming)" title="Semaphore (programming)">semaphores</a> and <a href="Interface_(computer_science)" class="mw-redirect" title="Interface (computer science)">interface</a> access.
</p><p>The Banker's algorithm derives its name from the fact that this algorithm could be used in a banking system to ensure that the bank does not run out of resources, because the bank would never allocate its money in such a way that it can no longer satisfy the needs of all its customers.<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> By using the Banker's algorithm, the bank ensures that when customers request money the bank never leaves a safe state. If the customer's request does not cause the bank to leave a safe state, the cash will be allocated, otherwise the customer must wait until some other customer deposits enough.
</p><p>Basic data structures to be maintained to implement the Banker's algorithm:
</p><p>Let <span class="texhtml mvar" style="font-style:italic;">n</span> be the number of processes in the system and <span class="texhtml mvar" style="font-style:italic;">m</span> be the number of resource types. Then we need the following data structures:
</p>
<ul><li>Available: A vector of length m indicates the number of available resources of each type. If Available[j] = k, there are k instances of resource type R<sub>j</sub> available.</li>
<li>Max: An <span class="texhtml mvar" style="font-style:italic;">n</span> × <span class="texhtml mvar" style="font-style:italic;">m</span> matrix defines the maximum demand of each process. If Max[i,j] = k, then P<sub>i</sub> may request at most k instances of resource type R<sub>j</sub>.</li>
<li>Allocation: An <span class="texhtml mvar" style="font-style:italic;">n</span> × <span class="texhtml mvar" style="font-style:italic;">m</span> matrix defines the number of resources of each type currently allocated to each process. If Allocation[i,j] = k, then process P<sub>i</sub> is currently allocated k instances of resource type R<sub>j</sub>.</li>
<li>Need: An <span class="texhtml mvar" style="font-style:italic;">n</span> × <span class="texhtml mvar" style="font-style:italic;">m</span> matrix indicates the remaining resource need of each process. If Need[i,j] = k, then P<sub>i</sub> may need k more instances of resource type R<sub>j</sub> to complete the task.</li></ul>
<p>Note: Need[i,j] = Max[i,j] - Allocation[i,j].
n=m-a.
</p>
<div class="mw-heading mw-heading3"><h3 id="Example">Example</h3></div>
<table class="wikitable inline">
<caption>Total system resources
</caption>
<tbody><tr>
<th>A
</th>
<th>B
</th>
<th>C
</th>
<th>D
</th></tr>
<tr>
<td>6
</td>
<td>5
</td>
<td>7
</td>
<td>6
</td></tr></tbody></table>
<table class="wikitable inline">
<caption>Available system resources
</caption>
<tbody><tr>
<th>A
</th>
<th>B
</th>
<th>C
</th>
<th>D
</th></tr>
<tr>
<td>3
</td>
<td>1
</td>
<td>1
</td>
<td>2
</td></tr></tbody></table>
<table class="wikitable inline">
<caption>Processes (currently allocated resources)
</caption>
<tbody><tr>
<th>
</th>
<th>A
</th>
<th>B
</th>
<th>C
</th>
<th>D
</th></tr>
<tr>
<th>P1
</th>
<td>1
</td>
<td>2
</td>
<td>2
</td>
<td>1
</td></tr>
<tr>
<th>P2
</th>
<td>1
</td>
<td>0
</td>
<td>3
</td>
<td>3
</td></tr>
<tr>
<th>P3
</th>
<td>1
</td>
<td>2
</td>
<td>1
</td>
<td>0
</td></tr></tbody></table>
<table class="wikitable inline">
<caption>Processes (maximum resources)
</caption>
<tbody><tr>
<th>
</th>
<th>A
</th>
<th>B
</th>
<th>C
</th>
<th>D
</th></tr>
<tr>
<th>P1
</th>
<td>3
</td>
<td>3
</td>
<td>2
</td>
<td>2
</td></tr>
<tr>
<th>P2
</th>
<td>1
</td>
<td>2
</td>
<td>3
</td>
<td>4
</td></tr>
<tr>
<th>P3
</th>
<td>1
</td>
<td>3
</td>
<td>5
</td>
<td>0
</td></tr></tbody></table>
<pre>Need = maximum resources - currently allocated resources
</pre>
<table class="wikitable inline">
<caption>Processes (possibly needed resources)
</caption>
<tbody><tr>
<th>
</th>
<th>A
</th>
<th>B
</th>
<th>C
</th>
<th>D
</th></tr>
<tr>
<th>P1
</th>
<td>2
</td>
<td>1
</td>
<td>0
</td>
<td>1
</td></tr>
<tr>
<th>P2
</th>
<td>0
</td>
<td>2
</td>
<td>0
</td>
<td>1
</td></tr>
<tr>
<th>P3
</th>
<td>0
</td>
<td>1
</td>
<td>4
</td>
<td>0
</td></tr></tbody></table>
<p><br>
</p>
<div class="mw-heading mw-heading3"><h3 id="Safe_and_unsafe_states">Safe and unsafe states</h3></div>
<p>A state (as in the above example) is considered safe if it is possible for all processes to finish executing (terminate). Since the system cannot know when a process will terminate, or how many resources it will have requested by then, the system assumes that all processes will eventually attempt to acquire their stated maximum resources and terminate soon afterward. This is a reasonable assumption in most cases since the system is not particularly concerned with how long each process runs (at least not from a deadlock avoidance perspective). Also, if a process terminates without acquiring its maximum resource it only makes it easier on the system.
A safe state is considered to be the decision maker if it's going to process ready queue.
</p><p>Given that assumption, the algorithm determines if a state is <b>safe</b> by trying to find a hypothetical set of requests by the processes that would allow each to acquire its maximum resources and then terminate (returning its resources to the system). Any state where no such set exists is an <b>unsafe</b> state.
</p><p>We can show that the state given in the previous example is a safe state by showing that it is possible for each process to acquire its maximum resources and then terminate.
</p>
<ol><li>P1 needs 2 A, 1 B and 1 D more resources, achieving its maximum
<ul><li>[available resource: <span class="nowrap">⟨3 1 1 2⟩</span> − <span class="nowrap">⟨2 1 0 1⟩</span> = <span class="nowrap">⟨1 0 1 1⟩</span>]</li>
<li>The system now still has 1 A, no B, 1 C and 1 D resource available</li></ul></li>
<li>P1 terminates, returning 3 A, 3 B, 2 C and 2 D resources to the system
<ul><li>[available resource: <span class="nowrap">⟨1 0 1 1⟩</span> + <span class="nowrap">⟨3 3 2 2⟩</span> = <span class="nowrap">⟨4 3 3 3⟩</span>]</li>
<li>The system now has 4 A, 3 B, 3 C and 3 D resources available</li></ul></li>
<li>P2 acquires 2 B and 1 D extra resources, then terminates, returning all its resources
<ul><li>[available resource: <span class="nowrap">⟨4 3 3 3⟩</span> − <span class="nowrap">⟨0 2 0 1⟩</span> + <span class="nowrap">⟨1 2 3 4⟩</span> = <span class="nowrap">⟨5 3 6 6⟩</span>]</li>
<li>The system now has 5 A, 3 B, 6 C and 6 D resources</li></ul></li>
<li>P3 acquires 1 B and 4 C resources and terminates.
<ul><li>[available resource: <span class="nowrap">⟨5 3 6 6⟩</span> − <span class="nowrap">⟨0 1 4 0⟩</span> + <span class="nowrap">⟨1 3 5 0⟩</span> = <span class="nowrap">⟨6 5 7 6⟩</span>]</li>
<li>The system now has all resources: 6 A, 5 B, 7 C and 6 D</li></ul></li>
<li>Because all processes were able to terminate, this state is safe</li></ol>
<p>For an example of an unsafe state, consider what would happen if process 2 was holding 1 unit of resource B at the beginning.
</p>
<div class="mw-heading mw-heading3"><h3 id="Requests">Requests</h3></div>
<p>When the system receives a request for resources, it runs the Banker's algorithm to determine if it is safe to grant the request.
The algorithm is fairly straightforward once the distinction between safe and unsafe states is understood.
</p>
<ol><li>Can the request be granted?
<ul><li>If not, the request is impossible and must either be denied or put on a waiting list</li></ul></li>
<li>Assume that the request is granted</li>
<li>Is the new state safe?
<ul><li>If so grant the request</li>
<li>If not, either deny the request or put it on a waiting list</li></ul></li></ol>
<p><i>Whether the system denies or postpones an impossible or unsafe request is a decision specific to the operating system.</i>
</p>
<div class="mw-heading mw-heading4"><h4 id="Example_2">Example</h4></div>
<p>Starting in the same state as the previous example started in, assume process 1 requests 2 units of resource C.
</p>
<ol><li>There is not enough of resource C available to grant the request</li>
<li>The request is denied</li></ol>
<p><br>
On the other hand, assume process 3 requests 1 unit of resource C.
</p>
<ol><li>There are enough resources to grant the request</li>
<li>Assume the request is granted
<ul><li>The new state of the system would be:</li></ul></li></ol>
<pre> Available system resources
A B C D
Free 3 1 0 2
</pre>
<pre> Processes (currently allocated resources):
A B C D
P1 1 2 2 1
P2 1 0 3 3
P3 1 2 2 0
</pre>
<pre> Processes (maximum resources):
A B C D
P1 3 3 2 2
P2 1 2 3 4
P3 1 3 5 0
</pre>
<ol><li>Determine if this new state is safe
<ol><li>P1 can acquire 2 A, 1 B and 1 D resources and terminate</li>
<li>Then, P2 can acquire 2 B and 1 D resources and terminate</li>
<li>Finally, P3 can acquire 1 B and 3 C resources and terminate</li>
<li>Therefore, this new state is safe</li></ol></li>
<li>Since the new state is safe, grant the request</li></ol>
<p><br>
Final example: from the state we started at, assume that process 2 requests 1 unit of resource B.
</p>
<ol><li>There are enough resources</li>
<li>Assuming the request is granted, the new state would be:</li></ol>
<pre> Available system resources:
A B C D
Free 3 0 1 2
</pre>
<pre> Processes (currently allocated resources):
A B C D
P1 1 2 5 1
P2 1 1 3 3
P3 1 2 1 0
</pre>
<pre> Processes (maximum resources):
A B C D
P1 3 3 2 2
P2 1 2 3 4
P3 1 3 5 0
</pre>
<ol><li>Is this state safe? Assuming P1, P2, and P3 request more of resource B and C.
<ul><li>P1 is unable to acquire enough B resources</li>
<li>P2 is unable to acquire enough B resources</li>
<li>P3 is unable to acquire enough B resources</li>
<li>No process can acquire enough resources to terminate, so this state is not safe</li></ul></li>
<li>Since the state is unsafe, deny the request</li></ol>
<div class="mw-highlight mw-highlight-lang-numpy mw-content-ltr" dir="ltr"><pre><span class="kn">import</span><span class="w"> </span><span class="nn">numpy</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">np</span>

<span class="n">n_processes</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="nb">input</span><span class="p">(</span><span class="s2">"Number of processes? "</span><span class="p">))</span>
<span class="n">n_resources</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="nb">input</span><span class="p">(</span><span class="s2">"Number of resources? "</span><span class="p">))</span>

<span class="n">available_resources</span> <span class="o">=</span> <span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">input</span><span class="p">(</span><span class="s2">"Claim vector? "</span><span class="p">)</span><span class="o">.</span><span class="kp">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">)]</span>

<span class="n">currently_allocated</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="kp">array</span><span class="p">([</span>
<span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">input</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Currently allocated for process </span><span class="si">{</span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="si">}</span><span class="s2">? "</span><span class="p">)</span><span class="o">.</span><span class="kp">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">)]</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">n_processes</span><span class="p">)</span>
<span class="p">])</span>

<span class="n">max_demand</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="kp">array</span><span class="p">([</span>
<span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">input</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Maximum demand from process </span><span class="si">{</span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="si">}</span><span class="s2">? "</span><span class="p">)</span><span class="o">.</span><span class="kp">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">)]</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">n_processes</span><span class="p">)</span>
<span class="p">])</span>

<span class="n">total_available</span> <span class="o">=</span> <span class="n">available_resources</span> <span class="o">-</span> <span class="n">np</span><span class="o">.</span><span class="kp">sum</span><span class="p">(</span><span class="n">currently_allocated</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
<span class="n">running</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="kp">ones</span><span class="p">(</span><span class="n">n_processes</span><span class="p">)</span> <span class="c1"># An array with n_processes 1's to indicate if process is yet to run</span>

<span class="k">while</span> <span class="n">np</span><span class="o">.</span><span class="n">count_nonzero</span><span class="p">(</span><span class="n">running</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
<span class="n">at_least_one_allocated</span> <span class="o">=</span> <span class="kc">False</span>
<span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">n_processes</span><span class="p">):</span>
<span class="k">if</span> <span class="n">running</span><span class="p">[</span><span class="n">p</span><span class="p">]:</span>
<span class="k">if</span> <span class="nb">all</span><span class="p">(</span><span class="n">i</span> <span class="o">&gt;=</span> <span class="mi">0</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">total_available</span> <span class="o">-</span> <span class="p">(</span><span class="n">max_demand</span><span class="p">[</span><span class="n">p</span><span class="p">]</span> <span class="o">-</span> <span class="n">currently_allocated</span><span class="p">[</span><span class="n">p</span><span class="p">])):</span>
<span class="n">at_least_one_allocated</span> <span class="o">=</span> <span class="kc">True</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">p</span><span class="si">}</span><span class="s2"> is running"</span><span class="p">)</span>
<span class="n">running</span><span class="p">[</span><span class="n">p</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span>
<span class="n">total_available</span> <span class="o">+=</span> <span class="n">currently_allocated</span><span class="p">[</span><span class="n">p</span><span class="p">]</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">at_least_one_allocated</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">"Unsafe"</span><span class="p">)</span>
<span class="k">break</span> <span class="c1"># exit</span>
<span class="k">else</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">"Safe"</span><span class="p">)</span>
</pre></div>
<div class="mw-heading mw-heading2"><h2 id="Limitations">Limitations</h2></div>
<p>Like the other algorithms, the Banker's algorithm has some limitations when implemented. Specifically, it needs to know how much of each resource a process could possibly request. In most systems, this information is unavailable, making it impossible to implement the Banker's algorithm. Also, it is unrealistic to assume that the number of processes is static since in most systems the number of processes varies dynamically. Moreover, the requirement that a process will eventually release all its resources (when the process terminates) is sufficient for the correctness of the algorithm, however it is not sufficient for a practical system. Waiting for hours (or even days) for resources to be released is usually not acceptable.
</p>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */


.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}


/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */


.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}


/* end https://en.wikipedia.org/ */
</style><cite id="CITEREFDijkstra" class="citation book cs1"><a href="Edsger_W._Dijkstra" title="Edsger W. Dijkstra">Dijkstra, Edsger W.</a> <a rel="nofollow" class="external text" href="http://www.cs.utexas.edu/users/EWD/ewd01xx/EWD108.PDF"><i>Een algorithme ter voorkoming van de dodelijke omarming (EWD-108)</i></a> <span class="cs1-format">(PDF)</span>. E.W. Dijkstra Archive. Center for American History, <a href="University_of_Texas_at_Austin" title="University of Texas at Austin">University of Texas at Austin</a>.</cite> (<a rel="nofollow" class="external text" href="http://www.cs.utexas.edu/users/EWD/transcriptions/EWD01xx/EWD108.html">transcription</a>) (in Dutch; <i>An algorithm for the prevention of the <a href="Deadlock_(computer_science)" title="Deadlock (computer science)">deadly embrace</a></i>)</span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text"><cite id="CITEREFSilberschatz,_Galvin,_&amp;_Gagne2013" class="citation book cs1">Silberschatz, Galvin, &amp; Gagne (2013). <i>Operating System Concepts, 9th Edition</i>. Wiley. p.&nbsp;330. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>978-1-118-06333-0</bdi>.</cite><span class="cs1-maint citation-comment"><code class="cs1-code">{{cite book}}</code>: CS1 maint: multiple names: authors list (link)</span></span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="Further_reading">Further reading</h2></div>
<ul><li>"<a rel="nofollow" class="external text" href="https://web.archive.org/web/20101013000653/http://codex.cs.yale.edu/avi/os-book/OS7/os7c/index.html">Operating System Concepts</a>" by Silberschatz, Galvin, and Gagne (pages 259-261 of the 7th edition)</li>
<li>"<a rel="nofollow" class="external text" href="https://web.archive.org/web/20140924121328/http://codex.cs.yale.edu/avi/os-book/OS8/os8c/index.html">Operating System Concepts</a>" by Silberschatz, Galvin, and Gagne (pages 298-300 of the 8th edition)</li>
<li><cite id="CITEREFDijkstra" class="citation book cs1"><a href="Edsger_W._Dijkstra" title="Edsger W. Dijkstra">Dijkstra, Edsger W.</a> <a rel="nofollow" class="external text" href="http://www.cs.utexas.edu/users/EWD/ewd06xx/EWD623.PDF"><i>The mathematics behind the Banker's Algorithm (EWD-623)</i></a> <span class="cs1-format">(PDF)</span>. E.W. Dijkstra Archive. Center for American History, <a href="University_of_Texas_at_Austin" title="University of Texas at Austin">University of Texas at Austin</a>.</cite> (<a rel="nofollow" class="external text" href="http://www.cs.utexas.edu/users/EWD/transcriptions/EWD06xx/EWD623.html">transcription</a>) (1977), published as pages 308–312 of Edsger W. Dijkstra, <i>Selected Writings on Computing: A Personal Perspective</i>, Springer-Verlag, 1982. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-387-90652-5</bdi></li></ul>
<div class="navbox-styles"><style data-mw-deduplicate="TemplateStyles:r1129693374">
/* start https://en.wikipedia.org/ */


.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}


/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1126788409">
/* start https://en.wikipedia.org/ */


.mw-parser-output .plainlist ol,.mw-parser-output .plainlist ul{line-height:inherit;list-style:none;margin:0;padding:0}.mw-parser-output .plainlist ol li,.mw-parser-output .plainlist ul li{margin-bottom:0}


/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1236075235">
/* start https://en.wikipedia.org/ */


.mw-parser-output .navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.mw-parser-output .navbox .navbox{margin-top:0}.mw-parser-output .navbox+.navbox,.mw-parser-output .navbox+.navbox-styles+.navbox{margin-top:-1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output .navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background-color:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.5em;border-color:#fdfdfd}.mw-parser-output .navbox-list-with-group{text-align:left;border-left-width:2px;border-left-style:solid}.mw-parser-output tr+tr>.navbox-abovebelow,.mw-parser-output tr+tr>.navbox-group,.mw-parser-output tr+tr>.navbox-image,.mw-parser-output tr+tr>.navbox-list{border-top:2px solid #fdfdfd}.mw-parser-output .navbox-title{background-color:#ccf}.mw-parser-output .navbox-abovebelow,.mw-parser-output .navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background-color:#ddf}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background-color:#e6e6ff}.mw-parser-output .navbox-even{background-color:#f7f7f7}.mw-parser-output .navbox-odd{background-color:transparent}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}body.skin--responsive .mw-parser-output .navbox-image img{max-width:none!important}@media print{body.ns-0 .mw-parser-output .navbox{display:none!important}}


/* end https://en.wikipedia.org/ */
</style></div><div role="navigation" class="navbox" aria-labelledby="Edsger_Dijkstra318" style="padding:3px"><table class="nowraplinks mw-collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="3"><style data-mw-deduplicate="TemplateStyles:r1239400231">
/* start https://en.wikipedia.org/ */


.mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar a>span,.mw-parser-output .navbar a>abbr{text-decoration:inherit}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}html.skin-theme-clientpref-night .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}@media(prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}}@media print{.mw-parser-output .navbar{display:none!important}}


/* end https://en.wikipedia.org/ */
</style><div id="Edsger_Dijkstra318" style="font-size:114%;margin:0 4em"><a href="Edsger_W._Dijkstra" title="Edsger W. Dijkstra">Edsger Dijkstra</a></div></th></tr><tr><th scope="row" class="navbox-group" style="width:1%">Works</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><i>A Primer of ALGOL 60 Programming</i> (book)</li>
<li><i>Structured Programming</i> (book)</li>
<li><i>A Discipline of Programming</i> (book)</li>
<li><i>A Method of Programming</i> (book)</li>
<li><i>Predicate Calculus and Program Semantics</i> (book)</li>
<li><i>Selected Writings on Computing: A Personal Perspective</i> (book)</li>
<li><i>A Note on Two Problems in Connexion with Graphs</i></li>
<li><i>Cooperating Sequential Processes</i></li>
<li><i>Solution of a Problem in Concurrent Programming Control</i></li>
<li><i>The Structure of the 'THE'-Multiprogramming System</i></li>
<li><i><a href="Go_To_Statement_Considered_Harmful" class="mw-redirect" title="Go To Statement Considered Harmful">Go To Statement Considered Harmful</a></i></li>
<li><i>Notes on Structured Programming</i></li>
<li><i>The Humble Programmer</i></li>
<li><i>Programming Considered as a Human Activity</i></li>
<li><i>How Do We Tell Truths That Might Hurt?</i></li>
<li><i>On the Role of Scientific Thought</i></li>
<li><i>Self-stabilizing Systems in Spite of Distributed Control</i></li>
<li><i><a href="On_the_Cruelty_of_Really_Teaching_Computer_Science" title="On the Cruelty of Really Teaching Computer Science">On the Cruelty of Really Teaching Computer Science</a></i></li>
<li><a href="Edsger_W._Dijkstra#Selected_publications" title="Edsger W. Dijkstra">Selected papers</a></li>
<li><a href="EWDs" class="mw-redirect" title="EWDs">EWD manuscripts</a></li></ul>
</div></td><td class="noviewer navbox-image" rowspan="3" style="width:1px;padding:0 0 0 2px"><div><span typeof="mw:File"></span></div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Computer_science#Areas_of_computer_science" title="Computer science">Main research<br>areas</a></th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Theoretical_computer_science" title="Theoretical computer science">Theoretical computing science</a></li>
<li><a href="Software_engineering" title="Software engineering">Software engineering</a></li>
<li><a href="Systems_science" title="Systems science">Systems science</a></li>
<li><a href="Algorithm_design" class="mw-redirect" title="Algorithm design">Algorithm design</a> (<a href="Dijkstra's_algorithm" title="Dijkstra's algorithm">Dijkstra's algorithm</a>)</li>
<li><a href="Concurrent_computing" title="Concurrent computing">Concurrent computing</a></li>
<li><a href="Distributed_computing" title="Distributed computing">Distributed computing</a></li>
<li><a href="Formal_methods" title="Formal methods">Formal methods</a></li>
<li><a href="Programming_methodology" class="mw-redirect" title="Programming methodology">Programming methodology</a></li>
<li><a href="Programming_language_research" class="mw-redirect" title="Programming language research">Programming language research</a></li>
<li><a href="Software_design" title="Software design">Program design</a> and <a href="Software_development" title="Software development">development</a></li>
<li><a href="Software_architecture" title="Software architecture">Software architecture</a></li>
<li><a href="Philosophy_of_computer_science" title="Philosophy of computer science">Philosophy of computer programming and computing science</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Related<br>people</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Shlomi_Dolev" title="Shlomi Dolev">Shlomi Dolev</a></li>
<li><a href="Per_Brinch_Hansen" title="Per Brinch Hansen">Per Brinch Hansen</a></li>
<li><a href="Tony_Hoare" title="Tony Hoare">Tony Hoare</a></li>
<li><a href="Ole-Johan_Dahl" title="Ole-Johan Dahl">Ole-Johan Dahl</a></li>
<li><a href="Leslie_Lamport" title="Leslie Lamport">Leslie Lamport</a></li>
<li><a href="David_Parnas" title="David Parnas">David Parnas</a></li>
<li><a href="Jaap_A._Zonneveld" title="Jaap A. Zonneveld">Jaap A. Zonneveld</a></li>
<li><a href="Carel_S._Scholten" title="Carel S. Scholten">Carel S. Scholten</a></li>
<li><a href="Adriaan_van_Wijngaarden" title="Adriaan van Wijngaarden">Adriaan van Wijngaarden</a></li>
<li><a href="Niklaus_Wirth" title="Niklaus Wirth">Niklaus Wirth</a></li></ul>
</div></td></tr><tr><td class="navbox-abovebelow plainlist" colspan="3"><div>
<ul><li><span class="noviewer" typeof="mw:File"><span title="Wikiquote page"></span></span> <a href="https://en.wikiquote.org/wiki/Special:Search/Edsger_W._Dijkstra" class="extiw external" title="wikiquote:Special:Search/Edsger W. Dijkstra"><b>Wikiquote</b></a></li></ul>
</div></td></tr></tbody></table></div></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-06-11" href="https://en.wikipedia.org/wiki/?title=Banker's_algorithm&amp;oldid=1295138381">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>

</body></html>